package elasticSearch.Controller;


import elasticSearch.DAO.CustomerDAO;
import elasticSearch.DAO.InspectTaskExecDetailMapper;
import elasticSearch.Entity.Customer;
import elasticSearch.Entity.InspectTaskExecDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CustomerController {
    @Autowired
    private CustomerDAO customerDAO;


    @GetMapping("/add")
    public Iterable<Customer> addIndex() {
        Customer customer = Customer.builder()
            .ID("1")
            .name("lipor")
            .email("13132")
            .password("123")
            .sex("男").build();
        customerDAO.save(customer);
        Iterable<Customer> all = customerDAO.findAll();
        return all;
    }

    @GetMapping("/InspectTaskExecDetail")
    public Customer test() {
        Customer customer = Customer.builder()
            .ID("1")
            .name("lipor")
            .email("13132")
            .password("123")
            .sex("男").build();

        return customer;
    }

    @Autowired
    private UserService userService;
    @GetMapping("/register")
    public String register(){
        UserRegisterBO lipor = UserRegisterBO.builder().age(8).name("lipor").build();
        userService.register(lipor);
        return "success";
    }



    @Autowired
    private InspectTaskExecDetailMapper inspectTaskExecDetailMapper;

    @GetMapping("/add")
    public void add(){
        for (int i = 0; i < 20000; i++) {
            System.out.println("add:{}"+i);
            inspectTaskExecDetailMapper.insert(InspectTaskExecDetail.builder()
                    .inspectResult("{\n" +
                            "    \"steps\":[\n" +
                            "        {\n" +
                            "            \"msg\":\"正常\",\n" +
                            "            \"result\":\"EIP线路\",\n" +
                            "            \"name\":\"EIPtype\"\n" +
                            "        },\n" +
                            "        {\n" +
                            "            \"msg\":\"异常\",\n" +
                            "            \"result\":\"摄像头PING测告警，ONU异常\",\n" +
                            "            \"name\":\"onu\"\n" +
                            "        }\n" +
                            "    ],\n" +
                            "    \"conclusion\":\"接入网故障\",\n" +
                            "    \"result\":\"摄像头PING测告警，ONU异常\",\n" +
                            "    \"isMerge\":false\n" +
                            "}")
                    .build());
        }

    }

}
